//
//  HHNewsController.m
//  oschina
//
//  Created by hjl on 16/3/30.
//  Copyright © 2016年 hjl. All rights reserved.
//

#import "HHNewsController.h"
#import <AFNetworking.h>
#import "HHAccount.h"
#import "HHAccountTool.h"

@interface HHNewsController ()

/** 页码 */
@property (nonatomic, assign) int page;

@end

@implementation HHNewsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    HHAccount *account = [HHAccountTool account];
    
    NSString *str = @"/action/openapi/news_list";
    NSString *strUrl = [NSString stringWithFormat:@"%@%@", HHStrUrl, str];
    
    NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
    parameters[@"catalog"] = @(1);
    parameters[@"pageSize"] = @(20);
    parameters[@"page"] = @(self.page);
    parameters[@"dataType"] = @"json";
    parameters[@"access_token"] = account.access_token;

    
    [[AFHTTPSessionManager manager] POST:strUrl parameters:parameters progress:^(NSProgress * _Nonnull uploadProgress) {
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        HHLog(@"%@", responseObject);
        
        [self.tableView reloadData];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        HHLog(@"错误....%@", error);
        // 加载错误时结束刷新
        //[self.tableView.mj_header endRefreshing];
    }];

    
    
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/
@end
